home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / programming / assembly / ex4_number2 / sv_startnode.s / sv_startnode.s
Encoding:
Text File  |  1992-09-02  |  8.5 KB  |  307 lines

  1. *******************************************************************************
  2. * AmiExpress SV_Tools                   Copyright © 1994 2-Cool/EX4!
  3. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  4. * $Release    : 0.1 $
  5. * $Revision    : 1.01 $
  6. * $Date        : 12-Jan-94 $
  7. *
  8. * $Author(s)    : Written by 2-Cool/EX4! (In MC680x0 Assembly under Asm-One)
  9. * $Note(s)    : Position Independacy off a4 - (WARNING: DON`T TRASH A4!)
  10. *        : Execbase Ptr is cached so that if running in fastmem access
  11. *        : to execbase ptr is faster.
  12. *
  13. * $Purpose    : CLI/Arexx tools for /X...
  14. *******************************************************************************
  15. AbsExecBase    =    4            /* Execbase Definition */
  16. SUCCESS        =    0            /* result return codes... */
  17. VAR_ERROR    =    1            /* memory alloction failcode */
  18.  
  19. SV_ICONIFY       =181            ;iconify screen
  20. SV_UNICONIFY     =153            ;uniconify screen
  21. SV_SYSOPLOGIN    =154            ;sysop login
  22. SV_LOCAL     =155            ;local login
  23. SV_INSTANT       =170            ;remote login (instant)
  24. SV_ACCOUNTS      =156            ;account editing
  25. SV_CHAT          =157            ;
  26. SV_NODEOFFHOOK   =158            ;offhook node
  27. SV_EXITNODE      =159            ;offline node
  28. SV_INITMODEM     =160            ;reset modem
  29. SV_SYSOPCHAT     =161            ;sysop chat with user
  30. SV_RESERVE       =171            ;reserve node for user
  31. SV_CHATTOGGLE    =172
  32. SV_AESHELL       =174
  33. SV_CLIPBOARD     =175
  34. SV_START         =176
  35. SV_NEWMSG        =177
  36. SV_QUIETNODE     =178
  37. SV_SETNRAMS      =179
  38. SV_RESERVENODE   =180            ;reserve node
  39.  
  40. RESERVED_BLOCK10 =162
  41.  
  42. CSI        =    $1b
  43. CLS        macro
  44.         dc.b    CSI,'c',LF
  45.         endm
  46.         
  47. *-------------- Definition Includes...
  48.  
  49.         incdir    _include:
  50.         include    exec/exec.i
  51.         include    "include:exec/funcdef.i"
  52.         include    intuition/intuition.i
  53.         include    graphics/videocontrol.i
  54.         include    libraries/asl.i
  55.         include    libraries/gadtools.i
  56.         include    libraries/dos_lib.i
  57.         include    libraries/intuition_lib.i
  58.         include    libraries/graphics_lib.i
  59.         include    libraries/exec_lib.i
  60.         include    libraries/asl_lib.i
  61.         include    libraries/icon_lib.i
  62.         include    libraries/diskfont_lib.i
  63.         include    libraries/gadtools_lib.i
  64.         include    libraries/wb_lib.i
  65.         include    libraries/rexxsyslib_lib.i
  66.         include    libraries/utility_lib.i
  67.         include    libraries/dosextens.i
  68.         include    utility/tagitem.i
  69.         include    dos/datetime.i
  70.         include    libraries/reqtools.i
  71.         
  72. *-------------- Definition of Main Variables (Public) Block...
  73.  
  74.         STRUCTURE VarsBlock,0
  75.  
  76.         APTR    _ExecBase            /* ExecBase base */
  77.         APTR    _DOSBase            /* DOS lib base */
  78.         APTR    _DOSOutput            /* DOS output base */
  79.         APTR    _ArgPtr
  80.         ULONG    _ArgLen
  81.  
  82.         LABEL    vars_SIZEOF
  83.  
  84. *-------------- Definition of Macros...
  85.  
  86. PUSH        macro
  87.         movem.l    \1,-(sp)
  88.         endm
  89. PULL        macro
  90.         movem.l    (sp)+,\1
  91.         endm
  92. PUSHW        macro
  93.         movem.w    \1,-(sp)
  94.         endm
  95. PULLW        macro
  96.         movem.w    (sp)+,\1
  97.         endm
  98. PUSHR        macro
  99.         move.l    \1,-(sp)
  100.         endm
  101. PULLR        macro
  102.         move.l    (sp)+,\1
  103.         endm
  104. CALL        macro
  105.         jsr    _LVO\1(a6)
  106.         endm
  107. CALLJ        macro
  108.         jmp    _LVO\1(a6)
  109.         endm
  110. CALLREL        macro
  111.         move.l    \2(a4),a6
  112.         CALL    \1
  113.         endm
  114.         
  115. *******************************************************************************
  116. *-------------- Allocate our Variables (RS.) Area
  117.  
  118. ProgStart:    move.l    a0,a5
  119.         move.l    d0,d5
  120.  
  121.         move.l    #vars_SIZEOF,d0        ;length for our variables
  122.         move.l    #MEMF_PUBLIC+MEMF_CLEAR,d1 ;we want public mem, cleared
  123.         move.l    (AbsExecBase).w,a6    ;get SysBase
  124.         CALL    AllocMem        ;allocate it...
  125.         move.l    d0,a4            ;ptr to our RS.Variables base
  126.         bne.s    RSValid            ;did the alloc fail, if so exit
  127.         moveq    #VAR_ERROR,d0        ;Memory allocation fail code
  128.         rts                ;exit to dos...
  129.  
  130. *-------------- From here a4 points to our variables area (DON`T DESTROY A4!)
  131.  
  132. RSValid:    move.l    a6,(a4)            ;cache execptr in Public so if
  133.                         ;we are in fastmem were faster
  134.         move.l    a5,_ArgPtr(a4)
  135.         move.l    d5,_ArgLen(a4)
  136.         sf.b    (a5,d5.w)        ;null terminate arg string..
  137.  
  138. *-------------- Open DOS Library
  139.  
  140.         moveq    #0,d0            ;set lib version
  141.           lea    Dosname(pc),a1        ;lib name in a1
  142.           CALL    OpenLibrary        ;try to open library
  143.           move.l    d0,_DOSBase(a4)        ;store lib base
  144.           beq.w    ShutDown        ;cleanup and quit if fail
  145.  
  146. *-------------- Get DOS Output
  147.  
  148.         move.l    d0,a6            ;get dosbase
  149.         CALL    Output            ;get output base
  150.         move.l    d0,_DOSOutput(a4)    ;save outputbase
  151.  
  152. *-------------- Program starts here
  153.  
  154.         lea    About.Txt(pc),a0        ;format string
  155.         bsr.w    OSPutStr
  156.  
  157.         move.l    _ArgPtr(a4),a0
  158.         cmp.b    #"?",(a0)
  159.         bne.s    no_usage
  160.  
  161.         lea    Args.Txt(pc),a0        ;format string
  162.         bsr.w    OSPutStr
  163.         bra.w    ShutDown
  164.         
  165. no_usage    move.l    a5,a0
  166.         lea    ServerPortName(pc),a1
  167. *-------------- get 1st byte..
  168.         moveq    #10,d1
  169.         move.b    (a0)+,d0
  170.         cmp.b    #"0",d0
  171.         beq.s    its_a_zero
  172.         blt.s    bad_args
  173.         cmp.b    #"9",d0
  174.         bgt.s    bad_args
  175.         move.b    d0,9(a1)        ;set node number (part a)
  176.         bra.s    not_a_zero
  177.  
  178. its_a_zero:    moveq    #9,d1
  179.  
  180. *-------------- get 2nd byte..
  181. not_a_zero:    move.b    (a0)+,d0
  182.         beq.s    its_okay
  183.         cmp.b    #$a,d0
  184.         beq.s    its_okay
  185.         cmp.b    #"0",d0
  186.         blt.s    bad_args
  187.         cmp.b    #"9",d0
  188.         bgt.s    bad_args
  189.         move.b    d0,(a1,d1.w)
  190.  
  191. *-------------- get 3rd byte (should be zero or a LF)
  192.  
  193.         move.b    (a0)+,d0
  194.         beq.s    its_okay
  195.         cmp.b    #$a,d0
  196.         bne.s    bad_args
  197. its_okay:    move.l    #SV_START,d7        ;command
  198.         bsr    CallNode        ;send command to node...
  199.         bra.s    ShutDown
  200.         
  201. bad_args:    lea    BadArgs.Txt(pc),a0        ;format string
  202.         bsr.w    OSPutStr
  203.  
  204. *-------------- Program ends here
  205.  
  206. *******************************************************************************
  207. * Shutdown() - Free all allocated resources & exit program
  208. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  209. * Frees all previously allocated resources, sanity checks are made so only
  210. * allocated memory/open libraries will be removed.
  211. *******************************************************************************
  212. *-------------- Free DOS Library
  213.  
  214. ShutDown:    move.l    _DOSBase(a4),d0        ;dos lib base in a1
  215.         beq.s    RSFreeMem
  216.         move.l    d0,a1
  217.           CALL    CloseLibrary        ;close intuition
  218.         clr.l    _DOSBase(a4)        ;clear out base
  219.         
  220. *-------------- Free RS Variables Area
  221.  
  222. RSFreeMem:    move.l    a4,a1            ;ptr to our RS.Variables base
  223.         move.l    #vars_SIZEOF,d0        ;no. of bytes to free
  224.         move.l    (a4),a6            ;get execbase
  225.         CALL    FreeMem            ;free the memory
  226.  
  227.         moveq    #SUCCESS,d0        ;no return code
  228.         rts                ;exit...
  229.  
  230. *******************************************************************************
  231. * OSPutStr
  232. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  233. * Sends a ascii text string to current console output
  234. * $Inputs:    a0.l = String ptr (null terminated)
  235. *******************************************************************************
  236.  
  237. OSPutStr:    move.l    a0,d2
  238.         moveq    #-1,d3            ;d4=0
  239. .getlen2    addq.l    #1,d3            ;increase string length by 1
  240.         tst.b    (a0)+            ;increase position
  241.         bne.s    .getlen2        ;nope not found, so keep on
  242.  
  243.         move.l    _DOSOutput(a4),d1
  244.         move.l    _DOSBase(a4),a6
  245.         jmp    _LVOWrite(a6)        ;print error msg to cli
  246.  
  247. ******************************************************************************
  248. * String & Data Variable definitions
  249.  
  250. Dosname:    dc.b    'dos.library',0                ;dos lib name
  251.         even
  252.  
  253. CallNode:    move.l    (AbsExecBase).w,a6
  254.         jsr    _LVOFindPort(a6)        ;find comms port
  255.         move.l    d0,d6
  256.         bne.s    is_active
  257.  
  258.         lea    NotActive.Txt(pc),a0
  259.         bra    OSPutStr
  260.  
  261. is_active:    move.l    #256,d0
  262.         moveq    #MEMF_PUBLIC,d1
  263.         jsr    _LVOAllocMem(a6)        ;allocate structure
  264.         move.l    d0,a1
  265.         bne.s    DoCmd
  266.         rts
  267.  
  268. DoCmd:        move.b    #6,8(a1)
  269.         move.w    #256,18(a1)            ;init structure
  270.         clr.l    14(a1)
  271.         move.l    d7,224(a1)            ;command
  272.         moveq    #1,d1
  273.         move.l    d1,220(a1)            ;write()
  274.         move.l    d6,a0                ;portbase
  275.         jmp    _LVOPutMsg(a6)
  276.  
  277. Version:    dc.b    '$VER: SV_STARTNODE v1.0 ',0
  278.         even
  279. ServerPortName:    dc.b    'AEServer.',0,0,0
  280.         even
  281. About.Txt:    CLS    ; clear screen
  282.         dc.b    CSI,'[0m',CSI,'[1mSV_STARTNODE v1.0',CSI,'[0m ',CSI,'[33m(For use with /X BBS & Compatibles only!) ',CSI,'[0m',CSI,'[3mBy 2-Cool/EX4!',LF
  283.         dc.b    CSI,'[0mCopyright EX4 © 1993-94. All Rights Are Reserved.',LF
  284.         dc.b    'Last Assembled: 15-Oct-94.',LF
  285.         dc.b    $a
  286.         dc.b    0
  287.         even
  288. BadArgs.Txt:    dc.b    'Invalid Node number argument. Please specify an node in the range of 0-99!',$a
  289.         dc.b    'Use "?" for usage.',$a,$a,0
  290.         even        
  291. NotActive.Txt:    dc.b    'This Ami-Express node/port is not running!',$a,$a,$a
  292.         even
  293. Args.Txt:    dc.b    'Usage   : ',CSI,'[32mSV_STARTNODE ',CSI,'[31m<node number>',LF
  294.         dc.b    'Example : ',CSI,'[32mSV_STARTNODE ',CSI,'[31m0',LF,LF
  295.  
  296.         dc.b    'The node number range is from 0-99. This allows future compatibility ',$a
  297.         dc.b    'if Ami-Express (or compatibles) ever support upto 99 nodes in this ',$a
  298.         dc.b    'program format. The latest /X however only supports from 0-31. This',$a
  299.         dc.b    'program is intended to be used from a CLI/Arexx script',$a,$a
  300.         dc.b    CSI,'[0m'
  301.         dc.b    'This utility may not be supplied with any commercial package without',$a
  302.         dc.b    'written consent from either IDS or EX4. It may NOT be placed on any ',$a
  303.         dc.b    'CD-Rom media without signed & written notification from the authors ',$a
  304.         dc.b    'allowing such activities. Full copyright is held by IDS and EX4.',$a,$a
  305.         dc.b    0
  306.